from rest_framework import serializers

from apps.aiauth.serializers import Users
from apps.job.models import Applyjob, CommentsJob, Interviews


class CommentsJobSerializers(serializers.ModelSerializer):
    class Meta:
        model = CommentsJob
        fields = "__all__"


class InterviewsSerializers(serializers.ModelSerializer):
    time = serializers.DateTimeField('%Y-%m-%d')
    create_time = serializers.DateTimeField('%Y-%m-%d %H:%M')

    class Meta:
        model = Interviews
        fields = "__all__"


class ApplyJob_UserSerializers(serializers.ModelSerializer):
    class Meta:
        model = Users
        fields = ('studentid', 'username')


class ApplyjobSerializers(serializers.ModelSerializer):
    commentsjob = CommentsJobSerializers(many=True)
    interviews = InterviewsSerializers(many=True)
    user = ApplyJob_UserSerializers()
    apply_time = serializers.DateTimeField('%Y-%m-%d')
    create_time = serializers.DateTimeField('%Y-%m-%d %H:%M')

    class Meta:
        model = Applyjob
        fields = ('applyjob_id', 'user', 'job_name', 'apply_time', 'apply_channel', 'offer', 'summary', 'company',
                  "company_contact", 'create_time', 'job_type', 'commentsjob', 'interviews')
